<script lang="tsx">
import Vue from 'vue'
import { Component } from 'vue-property-decorator'

@Component

export default class Index extends Vue {
    public getLogoTitle () {
        if (typeof this.$logo_title !== 'function') {
            console.error('function $logo_title is not found in Vue.prototype!')
            return
        }

        let config!: {
            scopeName?: string
        }
        if (process.env.COMPILE_MODE === 'lib') {
            config = { scopeName: process.env.APP_SCOPE_NAME }
        }
        this.$logo_title(function (res) {
            const flag = res.code === 'success' && res.data
            if (!flag) return

            let link: HTMLLinkElement = document.querySelector('link[rel*="icon"]') || document.createElement('link')
            link.type = 'image/x-icon'
            link.rel = 'icon'
            link.href = res.data
        }, null, config)
    }

    public created () {
        // !!! 以下内容勿删 !!!(设置组织缩略图)
        this.getLogoTitle()
    }

    public mounted () {
        // !!! 以下内容勿删 !!!(子项目注册到portal)
        if (this.isPortal) {
            this.$store.commit('finish')
        }
    }
    
    public render (): JSX.Element {
        return (
            <router-view></router-view>
        )
    }
}
</script>
